<template>
  <div class="view-fill">
    <div v-show="!assetDetailInfo.visible" class="app-container-flex">
      <NewFullScreen
        v-model="showDialog"
        :title="title"
        :need-return="false"
        :btn-list="fullInfo.btnList"
        :newFullScreenClass="newFullScreenClass"
      >
        <template v-slot:full-button>
          <ScanInputBox
            :query="scanInfo.query"
            :api="scanInfo.api"
            style="margin-right: 10px"
            @callback="onCallBackScanData"
          />
        </template>
        <div id="table-list">
          <div class="model-panel">
            <div class="model-panel-title">
              <p>{{ $t('basic_information') }}</p>
            </div>
            <div class="model-panel-body">
              <basic-information :info="infoList" />
            </div>
          </div>

          <div id="table-box" class="model-panel">
            <div class="model-panel-title">
              <Tooltip :text="$t('detailInfo')" />
            </div>
            <div class="model-panel-body">
              <!-- 条件栏 -->
              <div class="filter-wrapper">
                <NewPageFilter
                  v-model:query="filterInfo.query.queryMap"
                  :query-more-json="true"
                  :filter-list="filterInfo.searchList"
                  :filter-btn="filterInfo.searchBtn"
                  :clear-type="clearType"
                >
                </NewPageFilter>
                <el-button
                  v-if="$permission('assetInventoryTask:addSurplus')"
                  @click="createSurplus"
                  >新增盘盈</el-button
                >
              </div>
              <div class="flex_full_item">
                <!-- 表格 -->
                <page-table
                  v-model:data="tableInfo.list"
                  :pager="false"
                  :check-box="false"
                  :highlight-row="false"
                  :tab-index="true"
                  :index-method="indexMethod"
                  :field-list="tableInfo.fieldList"
                  :row-class-name="tableRowClassName"
                  :handle="tableInfo.handle"
                  :isDynamic="false"
                  @sortChange="sortChange"
                >
                  <template v-slot:col-preAssetName="scope">
                    <span
                      v-if="scope.row.inventoryStatus != '5'"
                      class="slip-edit"
                      @click="showAssetDetail(scope.row)"
                      >{{ scope.row.preAssetName }}</span
                    >
                    <span v-else>{{ scope.row.preAssetName }}</span>
                  </template>
                  <template v-slot:col-remark="scope">
                    <div class="remarkBox">
                      <el-input
                        v-model="scope.row.remark"
                        style="width: 120px"
                        placeholder="请输入备注"
                      ></el-input>
                      <span
                        class="slip-edit padding"
                        @click="saveRemark(scope.row, scope.$index)"
                        >保存</span
                      >
                    </div>
                  </template>
                  <template v-slot:col-inventoryPercent="scope">
                    <span>{{ scope.row.inventoryPercent || 0 }} %</span>
                  </template>
                  <template v-slot:col-filePath="scope">
                    <div
                      v-if="scope.row.filePath"
                      class="showImage"
                      @click="viewImg(scope.row, scope.$index)"
                    >
                      <el-image
                        class="image"
                        :src="action + scope.row.filePath"
                      ></el-image>
                    </div>
                    <tableUploadImg
                      v-else
                      :index="scope.$index"
                      @upDateUpload="upDateUpload"
                    />
                  </template>
                </page-table>
              </div>
            </div>
          </div>
        </div>
      </NewFullScreen>
    </div>

    <!-- 详情页 -->
    <asset-card-detail
      v-if="assetDetailInfo.visible"
      :id="assetDetailInfo.id"
      v-model:visible="assetDetailInfo.visible"
      :title="assetDetailInfo.title"
    />
    <loss
      v-if="lossInfo.visible"
      :table-row="lossInfo.data"
      v-model:show-dialog="lossInfo.visible"
      :title="lossInfo.title"
      @callback="callbackLoss"
    />
    <surplus
      v-if="surplusInfo.visible"
      :table-row="surplusInfo.data"
      v-model:show-dialog="surplusInfo.visible"
      :title="surplusInfo.title"
      :inventoryLocation="infoList.data.inventoryLocation"
      @callback="callbackSurplus"
    />
    <!-- <AssetCardModify
      v-if="surplusInfo.visible"
      :id="surplusInfo.id"
      v-model:visible="surplusInfo.visible"
      :title="surplusInfo.title"
      :type="surplusInfo.type"
      :current-accounting-interval="surplusInfo.currentAccountingInterval"
      :buildCardData="surplusInfo.buildCardData"
      :inventoryLocation="infoList.data.inventoryLocation"
      @returnModify="callbackSurplus"
    /> -->
    <EleGallery
      v-if="viewImgInfo.visible"
      v-model:show-dialog="viewImgInfo.visible"
      :file-list="viewImgInfo.list"
      :title="viewImgInfo.title"
      :show-delete="true"
      :multiple-sheets="true"
      @callbackEle="callbackEle"
    />
    <!-- 详情页 -->
    <asset-card-detail
      v-if="assetDetailInfo.visible"
      :id="assetDetailInfo.id"
      v-model:visible="assetDetailInfo.visible"
      :title="assetDetailInfo.title"
    />
  </div>
</template>

<script setup name="IndividualItemDetails">
import PageTable from '@/components/PageTable/index'
import {
  getInventoryTaskOrderDetailCustomizeListAll,
  inventoryTaskOrderExcelOrder,
  inventoryTaskOrderPrintOrder,
  inventoryTaskOrderScan,
  getInventoryTaskOrderById,
  putInventoryTaskOrderDetail,
  createInsertInventorySurplus,
  updateInsertInventorySurplus,
  delInventoryTaskOrderDetail,
  getInventorySurplusRecord,
} from '@/api/asset'
import ScanInputBox from './ScanInputBox'
import EleGallery from '@/components/NewUpload/eleGallery'
import Loss from './loss'
import Surplus from './surplus'
import tableUploadImg from '@/components/NewUpload/tableUploadImg'
import AssetCardDetail from '@/views/asset/assetManage/assetCard/details'
import AssetCardModify from '@/views/asset/assetManage/assetCard/modify'
import { getCustomizeSetting } from '@/api/customize'
import { fatchTemplateByCode } from '@/api/base'
import { getCurrentFiscalPeriod } from '@/api/core'
import axios from 'axios'
import _ from 'lodash'
const { proxy } = getCurrentInstance()
const emits = defineEmits()
const props = defineProps(['visible', 'title', 'tableRowId'])

const scanInfo = ref({
  query: {
    orderId: props.tableRowId,
    code: '',
  },
  api: inventoryTaskOrderScan,
})
const action = ref(axios.defaults.baseURL + '/pub')
// 过滤相关配置
const filterInfo = ref({
  sortArr: [],
  query: {
    sortString: '',
    customizeUserVO: {},
    queryMap: {
      orderId: {
        queryType: 'EQUALS',
        queryCategory: 'AND',
        value: props.tableRowId,
      },
    },
    queryParams: {},
  },
  searchList: [],
  searchBtn: [
    { type: 'button', label: '搜索', event: search },
    { type: 'button', label: '重置', event: clearSearch },
  ],
})
const infoList = ref({
  data: {},
  fieldList: [
    { label: '任务单号', value: 'orderNo' },
    { label: '状态', value: 'statusValue' },
    {
      label: '盘点位置',
      value: 'inventoryLocationValue',
    },
    { label: '任务负责人', value: 'taskResponseUserName' },
    { label: '盘点人', value: 'taskInventoryUserName' },
    { label: '任务进度', value: 'inventoryPercent', type: 'progress' },
    { label: '应盘', value: 'inventoryQty' },
    { label: '待盘', value: 'pendInventoryQty' },
    { label: '相符', value: 'matchQty' },
    { label: '盘盈', value: 'surplusQty' },
    { label: '盘亏', value: 'lossQty' },
    { label: '创建人', value: 'createUserName' },
    { label: '创建时间', value: 'createTime' },
    { label: '计划开始日期', value: 'planStartDate' },
    { label: '计划结束日期', value: 'planEndDate' },
  ],
})
// 表格相关
const tableInfo = ref({
  ref: null,
  refresh: 1,
  initCurpage: 1,
  data: [],
  selections: [],
  fieldList: [],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '100',
    btList: [
      {
        label: '相符',
        event: matchRow,
        show: proxy.$permission('assetInventoryTask:match'),
        ifRender: ifRenderCheck,
      },
      {
        label: '盘亏',
        event: lossRow,
        show: proxy.$permission('assetInventoryTask:loss'),
        ifRender: ifRenderCheck,
      },
      {
        label: '重盘',
        event: resetRow,
        show: proxy.$permission('assetInventoryTask:reset'),
        ifRender: ifRenderRest,
      },
      {
        label: '编辑盘盈',
        event: editSurplusRow,
        show: proxy.$permission('assetInventoryTask:editSurplus'),
        ifRender: ifRenderSurplus,
      },
      {
        label: '删除盘盈',
        event: delSurplusRow,
        popconfirmText: '删除后将改变数据,是否继续？',
        show: proxy.$permission('assetInventoryTask:delSurplus'),
        ifRender: ifRenderSurplus,
      },
    ],
  },
  list: [],
})
const fullInfo = ref({
  btnList: [
    { value: 'button', type: 'slot' },
    {
      label: '打印',
      event: print,
      show: proxy.$permission('assetInventoryTask:printModify'),
    },
    {
      label: '导出excel',
      event: exportExcel,
      show: proxy.$permission('assetInventoryTask:excel'),
    },
    { label: '返回', event: returnBank, show: true },
  ],
})
const surplusInfo = ref({
  visible: false,
  data: {},
  row: {},
  title: '',
  index: '',
  type: '',
})
const assetDetailInfo = ref({
  visible: false,
  id: '',
  title: '资产详情',
})
const lossInfo = ref({
  visible: false,
  data: {},
  title: '',
  index: '',
})
const viewImgInfo = ref({
  visible: false,
  list: [],
  title: '盘点图片',
  row: {},
  index: '',
})
const clearType = ref(true)
const obj = ref({
  surplusStatusValue: {
    label: '状态',
    value: 'surplusStatusValue',
    asValue: 'surplusStatus',
    componentType: 'select-model',
    code: 'asset_inventory_surplus_status',
    show: false,
    hidden: true,
  },
  statusValue: {
    label: '状态',
    value: 'statusValue',
    asValue: 'status',
    componentType: 'select-model',
    code: 'asset_inventory_task_status',
    show: false,
    hidden: true,
  },
  filePath: {
    label: '盘点图片',
    value: 'filePath',
    type: 'slot',
    show: false,
    hidden: true,
  },
  remark: {
    label: '盘点备注',
    value: 'remark',
    componentType: 'input',
    type: 'slot',
    show: false,
    minWidth: '200px',
    hidden: true,
  },
  inventoryPercent: {
    label: '盘点进度',
    value: 'inventoryPercent',
    componentType: 'input',
    type: 'slot',
    show: false,
    hidden: true,
  },
})

const loading = ref(false)
const listPage = ref(0)
const scrollTop = ref(0)
const oldDataIndex = ref(-1)
const box = ref(undefined)
const newFullScreenClass = ref('scrollY' + new Date().getTime())
const showDialog = computed({
  get() {
    return props.visible
  },
  set(newValue) {
    emits('update:visible', newValue) // 更新父组件visible
  },
})
onMounted(() => {
  box.value = document.getElementsByClassName(newFullScreenClass.value)[0]
  box.value && box.value.addEventListener('scroll', throttle(handleScroll, 0))
})
onBeforeUnmount(() => {
  box.value &&
    box.value.removeEventListener('scroll', throttle(handleScroll, 0))
})

watch(
  () => tableInfo.value.data,
  (val) => {
    if (val.length) {
      val.forEach((item, index) => {
        item.tableIndex = index + 1
      })
    }
  },
  {
    deep: true,
  }
)
tableInfo.value.fieldList = Object.values({
  ...proxy.$fn.deepClone(proxy.$fieldfList.FieldList),
  ...proxy.$fn.deepClone(obj.value),
})
filterInfo.value.searchList = Object.values({
  ...proxy.$fn.deepClone(proxy.$fieldfList.FieldList),
  ...proxy.$fn.deepClone(obj.value),
})
getCustomize()

function handleScroll() {
  // 获取eagleMapContainer的真实高度
  const box = document.getElementsByClassName(newFullScreenClass.value)[0]
  const boxHeight = box.offsetHeight
  // 获取table_list的真实高度（浮动内容的真实高度）
  const tableHeight = document.getElementById('table-list').offsetHeight
  const tableDom = document.getElementById('table-box')
  // boxHeight和滑块浮动的高度相差小于50 && 不在加载中 && 不是最后一页
  if (
    tableHeight - (box.scrollTop + boxHeight) < 50 &&
    !loading.value &&
    listPage.value + 1 < tableInfo.value.data.length / 50
  ) {
    // 第一次触发时，记录滑块高度
    // data里scrollTop，listPage默认为0
    if (!scrollTop.value) {
      scrollTop.value = box.scrollTop
    }
    // 触发下拉加载更多
    queryMoreStat(true, tableHeight, boxHeight)
  } else if (box.scrollTop <= tableDom.offsetTop + 200 && !loading.value) {
    // 如果滑块上拉到顶部，则向上加载50条
    queryMoreStat(false, tableHeight, boxHeight)
  }
}
function queryMoreStat(type, tableHeight, boxHeight) {
  loading.value = true
  // 触底加载
  const tableData = tableInfo.value.data
  if (type) {
    listPage.value = listPage.value + 1
    const centerPage = listPage.value * 50
    const startPage = centerPage >= 50 ? centerPage - 50 : centerPage
    const endPage = centerPage + 50
    const newList = tableData.slice(startPage, endPage)
    if (listPage.value > 0) {
      const box = document.getElementsByClassName(newFullScreenClass.value)[0]
      // 视图跳到触发的数据，补回50的高度差值
      box.scrollTop = scrollTop.value - 50
    }
    tableInfo.value.list = newList
  } else {
    // 置顶加载
    if (listPage.value > 0) {
      listPage.value = listPage.value - 1
      const centerPage = listPage.value * 50
      const startPage = centerPage >= 50 ? centerPage - 50 : centerPage
      const endPage = centerPage + 50
      const newList = tableData.slice(startPage, endPage)
      if (listPage.value > 0) {
        const tableDom = document.getElementById('table-box')
        const box = document.getElementsByClassName(newFullScreenClass.value)[0]
        box.scrollTop = tableHeight - scrollTop.value - boxHeight
        // box.scrollTop = tableDom.offsetTop + 220
      }
      tableInfo.value.list = newList
    } else {
      tableInfo.value.list = tableData.slice(0, 50)
    }
  }
  proxy.$nextTick(() => {
    loading.value = false
  })
}
function indexMethod(row) {
  // const centerPage = listPage.value * 50
  // const startPage = centerPage >= 50 ? centerPage - 50 : centerPage
  // return startPage + index + 1;
  return row.tableIndex
}
function debounce(fn, delay) {
  let timer = null
  return function () {
    if (timer !== null) {
      clearTimeout(timer)
    }
    timer = setTimeout(fn, delay)
  }
}
function throttle(fn, delay) {
  let timer = null,
    startTime = new Date()
  return function () {
    let curTime = new Date()
    let remaining = delay - (curTime - startTime)
    clearTimeout(timer)
    if (remaining <= 0) {
      startTime = new Date()
      fn.apply(proxy, arguments)
    } else {
      timer = setTimeout(fn, remaining)
    }
  }
}
function ifRenderCheck(row) {
  return (
    row.inventoryStatus === 1 &&
    (infoList.value.data.status === 1 || infoList.value.data.status === 2)
  )
}
function ifRenderSurplus(row) {
  return (
    row.inventoryStatus === 5 &&
    (infoList.value.data.status === 1 || infoList.value.data.status === 2)
  )
}
function ifRenderRest(row) {
  return (
    [2, 3, 4].includes(row.inventoryStatus) &&
    (infoList.value.data.status === 1 || infoList.value.data.status === 2)
  )
}
function matchRow(data, index) {
  //相符
  let row = proxy.$fn.deepClone(data)
  row.isChoice = false
  row.inventoryStatus = 2
  putInventoryTaskOrderDetail(row).then((res) => {
    if (res && res.success) {
      tableInfo.value.list[index] = res.data
      tableInfo.value.data[data.tableIndex - 1] = res.data

      getMain()
    }
  })
}
function lossRow(row, index) {
  //盘亏
  lossInfo.value.visible = true
  lossInfo.value.title = '盘亏说明'
  lossInfo.value.data = proxy.$fn.deepClone(row)
  lossInfo.value.index = index
}
function callbackLoss(data) {
  let index = lossInfo.value.index
  data.inventoryStatus = 4
  putInventoryTaskOrderDetail(data).then((res) => {
    if (res && res.success) {
      tableInfo.value.list[index] = res.data
      tableInfo.value.data[data.tableIndex - 1] = res.data

      getMain()
    }
  })
}
function saveRemark(data, index) {
  //保存备注
  putInventoryTaskOrderDetail(data).then((res) => {
    if (res && res.success) {
      tableInfo.value.list[index] = res.data
      tableInfo.value.data[data.tableIndex - 1] = res.data

      proxy.$message({
        message: `保存成功`,
        type: 'success',
        duration: 3500,
        showClose: true,
      })
    }
  })
}
function resetRow(data, index) {
  //重盘
  let row = proxy.$fn.deepClone(data)
  row.isChoice = false
  row.inventoryStatus = 1
  putInventoryTaskOrderDetail(row).then((res) => {
    if (res && res.success) {
      tableInfo.value.list[index] = res.data
      tableInfo.value.data[data.tableIndex - 1] = res.data

      getMain()
    }
  })
}
function createSurplus() {
  //新增盘盈
  surplusInfo.value.visible = true
  surplusInfo.value.title = '新增盘盈'
  surplusInfo.value.data = {}
  surplusInfo.value.index = ''
  surplusInfo.value.type = 'create'
  // getCurrentFiscalPeriod(2).then((resp) => {
  //   if (resp && resp.success && resp.data) {
  //     surplusInfo.value.currentAccountingInterval = resp.data.startDate
  //   } else {
  //     proxy.$message({
  //       type: 'error',
  //       duration: 3500,
  //       message: '未开启会计期间，请先开启会计期间!',
  //       showClose: true,
  //     })
  //   }
  //   proxy.$nextTick(() => {
  //     surplusInfo.value.visible = true
  //     surplusInfo.value.title = '新增盘盈'
  //     surplusInfo.value.type = 'createSurplus'
  //     surplusInfo.value.id = null
  //     surplusInfo.value.buildCardData = []
  //     surplusInfo.value.index = null
  //   })
  // })
}
function editSurplusRow(row, index) {
  //编辑盘盈
  getInventorySurplusRecord({ taskOrderDetailId: row.id }).then((res) => {
    if (res && res.success) {
      surplusInfo.value.visible = true
      surplusInfo.value.title = '编辑盘盈'
      surplusInfo.value.data = proxy.$fn.deepClone(res.data)
      surplusInfo.value.index = index
      surplusInfo.value.row = proxy.$fn.deepClone(row)
      surplusInfo.value.type = 'update'
    }
  })
}
function callbackSurplus(data, callback) {
  if (data) {
    data.taskOrderId = infoList.value.data.id
    data.taskOrderNo = infoList.value.data.orderNo
    data.inventoryStatus = 5
    let api =
      surplusInfo.value.type === 'update'
        ? updateInsertInventorySurplus
        : createInsertInventorySurplus
    api(data).then((res) => {
      if (res && res.success) {
        if (surplusInfo.value.type === 'update') {
          res.data.tableIndex = surplusInfo.value.row.tableIndex
          tableInfo.value.list[surplusInfo.value.index] = res.data
          tableInfo.value.data[surplusInfo.value.row.tableIndex - 1] = res.data
        } else {
          tableInfo.value.data.unshift(res.data)
          tableInfo.value.list = tableInfo.value.data.slice(0, 50)
        }
        getMain()
        callback()
      }
    })
  }
}
function delSurplusRow(row) {
  delInventoryTaskOrderDetail(row.id).then((res) => {
    if (res && res.success) {
      tableInfo.value.list = tableInfo.value.list.filter((item) => item !== row)
      tableInfo.value.data = tableInfo.value.data.filter(
        (item) => item.id !== row.id
      )
      getMain()
    }
  })
}
function upDateUpload(obj) {
  //上传图片返回
  let { data, index } = obj
  let row = proxy.$fn.deepClone(tableInfo.value.list[index])
  row.filePath = data[0]
  putInventoryTaskOrderDetail(row).then((res) => {
    if (res && res.success) {
      tableInfo.value.list[index] = res.data
      tableInfo.value.data[data.tableIndex - 1] = res.data

      getList()
    }
  })
}
function viewImg(row, index) {
  //查看图片
  if (!row.filePath) return
  viewImgInfo.value.row = row
  viewImgInfo.value.index = index
  viewImgInfo.value.visible = true
  viewImgInfo.value.list = [
    {
      name: row.filePath,
      url: action.value + row.filePath,
      uid: new Date().getTime() + (1 + Math.random()),
    },
  ]
}
function callbackEle() {
  let row = proxy.$fn.deepClone(viewImgInfo.value.row)
  let index = viewImgInfo.value.index
  row.filePath = ''
  putInventoryTaskOrderDetail(row).then((res) => {
    if (res && res.success) {
      tableInfo.value.list[index] = res.data
      tableInfo.value.data[data.tableIndex - 1] = res.data

      getList()
    }
  })
}
function clearSearch() {
  clearType.value = !clearType.value
  filterInfo.value.query.queryMap = proxy.$fn.deepClone(
    filterInfo.value.copyQueryMap
  )
  search()
}
function showAssetDetail(row) {
  assetDetailInfo.value.id = row.assetId
  assetDetailInfo.value.visible = true
}
function getMain() {
  getInventoryTaskOrderById(props.tableRowId).then((resp) => {
    if (resp && resp.success) {
      let data = resp.data
      infoList.value.data = resp.data
      let progress = proxy.$fn.accDiv(
        proxy.$fn.Subtr(data.inventoryQty, data.pendInventoryQty),
        data.inventoryQty
      )
      infoList.value.data.progress = _.floor(progress * 100)
    }
  })
}

// 获取列表
function getList() {
  getInventoryTaskOrderDetailCustomizeListAll(filterInfo.value.query).then(
    (resp) => {
      if (resp && resp.success) {
        resp.data.forEach((item, index) => {
          item.isChoice = false
        })
        tableInfo.value.data = resp.data
        tableInfo.value.list = tableInfo.value.data.slice(0, 50)
      }
    }
  )
}
// 搜索
function search() {
  getList()
}
// 触发事件
function handleEvent(event, data) {
  switch (event) {
    case 'tableCheck':
      tableInfo.value.selections = [...data]
      break
  }
}

function onCallBackScanData(code, callback) {
  let curIndex = 0
  let index = tableInfo.value.data.findIndex((item) => item.assetCode === code)
  if (index > -1) {
    tableInfo.value.data.forEach((item) => {
      item.isChoice = false
      if (item.assetCode === code) {
        item.isChoice = true
      }
    })
    scrollTable(curIndex, index)
    callback(true)
  } else {
    callback(false)
  }
}
function scrollTable(curIndex, itemIndex) {
  curIndex = itemIndex
  listPage.value = Math.floor(curIndex / 50)
  const centerPage = listPage.value * 50
  const startPage = centerPage >= 50 ? centerPage - 50 : centerPage
  const endPage = centerPage + 50
  tableInfo.value.list = tableInfo.value.data.slice(startPage, endPage)
  oldDataIndex.value = curIndex
}
function returnBank() {
  //返回
  showDialog.value = false
  emits('returnModify', { type: 'refresh' })
}
function print() {
  fatchTemplateByCode({
    resourceCode: 'assetInventoryTask:printModify',
    isDefault: 1,
  }).then((res) => {
    if (res && res.success) {
      let temp = proxy.$fn.getPrintTemp(res.data[0])
      getPrintData(temp)
    }
  })
}
function getPrintData(temp) {
  let query = proxy.$fn.deepClone(filterInfo.value.query)
  //query.queryMap.inventoryResult.value = dialogInfo.value.flag.toString();
  let param = {
    customizeDto: query,
    orderIds: [props.tableRowId],
  }
  inventoryTaskOrderPrintOrder(param).then((res) => {
    if (res.success && res) {
      let data = proxy.$fn.deepClone(res.data)
      let newData = data.map((item) => {
        return {
          ...item,
          ...item.orderInfo,
        }
      })
      proxy.$lodop.preview(temp, newData)
    }
  })
}
function exportExcel() {
  let query = proxy.$fn.deepClone(filterInfo.value.query)
  //query.queryMap.inventoryResult.value = dialogInfo.value.flag.toString();
  inventoryTaskOrderExcelOrder(query).then((resp) => {
    if (resp) {
      proxy.$fn.parseExcel(resp)
    }
  })
}
function tableRowClassName({ row }) {
  if (row.isChoice === true) {
    return 'success-row'
  }
}
function sortChange(column) {
  if (filterInfo.value.query.customizeUserVO.head.sortType === 0) {
    let arr = proxy.$fn.sortChange(column, filterInfo.value.sortArr)
    filterInfo.value.sortArr = arr
    filterInfo.value.query.sortString = arr.length ? arr.toString() : ''
    getList()
  }
}
function getCustomize() {
  let param = {
    tableKey:
      'assetAssetManageAssetInventoryTaskModify-com.slip.spd.entity.vo.asset.AssetInventoryTaskOrderDetailVO',
  }
  getCustomizeSetting(param).then((res) => {
    if (res && res.success) {
      let data = res.data
      filterInfo.value.query.customizeUserVO = data
      tableInfo.value.fieldList = proxy.$fn.setFieldList(
        tableInfo.value.fieldList,
        data.detail
      )
      let searchInfo = proxy.$fn.setSearchList(
        filterInfo.value.searchList,
        data.detail
      )
      filterInfo.value.query.queryMap = {
        ...searchInfo.queryMap,
        ...filterInfo.value.query.queryMap,
      }
      filterInfo.value.searchList = searchInfo.searchList
      filterInfo.value.searchList.forEach((item) => {
        item.event = search
      })
      filterInfo.value.copyQueryMap = proxy.$fn.deepClone(
        filterInfo.value.query.queryMap
      )
      if (props.tableRowId) {
        getMain()
        getList()
      }
    }
  })
}
</script>

<style scoped lang="scss">
.model-panel-title {
  display: flex;
  align-items: center;
}
:deep(.el-table) .row-color-f7ecc {
  background: #f7e7cc !important;
}
:deep(.el-table) .row-color-d7faea {
  background: #d7faea !important;
}
:deep(.el-table) .row-color-f5e5e5 {
  background: #f5e5e5 !important;
}
:deep(.showImage) {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  .image {
    max-width: 40px !important;
    max-height: 40px !important;
  }
}
.remarkBox {
  display: flex;
  align-items: center;
  justify-content: center;
  .padding {
    padding: 0 10px;
  }
}
</style>
